module(
    name = "portable_cc_toolchain",
    version = "2025.04.14",
)

bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "platforms", version = "0.0.11")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "aspect_bazel_lib", version = "2.13.0")

# https://github.com/abseil/abseil-cpp/pull/1794
# TODO use `repo_name = None` when it becomes available (Bazel 8.2.0)
bazel_dep(name = "abseil-cpp", version = "20250127.1")

bazel_dep(name = "stardoc", version = "0.8.0", dev_dependency = True)

# https://github.com/bazelbuild/bazel/issues/24426#issuecomment-2574862618
bazel_dep(name = "re2", version = "2024-07-02.bcr.1", dev_dependency = True)

host_platform = use_extension("@platforms//host:extension.bzl", "host_platform")
use_repo(host_platform, "host_platform")

assets = use_extension("//detail/assets:assets.bzl", "assets")
use_repo(assets, "llvm-x86_64-unknown-linux-gnu")
use_repo(assets, "llvm-aarch64-unknown-linux-gnu")
use_repo(assets, "llvm-arm64-apple-macos")
use_repo(assets, "llvm-x86_64-apple-macos")
use_repo(assets, "sysroot-x86_64-unknown-linux-gnu")
use_repo(assets, "sysroot-aarch64-unknown-linux-gnu")
use_repo(assets, "sysroot-armv7-unknown-linux-gnueabihf")

find_xcode_sdk = use_repo_rule("//detail/xcode:find.bzl", "find_xcode_sdk")

find_xcode_sdk(
    name = "xcode-macosx",
    sdk = "macosx",
)

find_xcode_sdk(
    name = "xcode-iphoneos",
    sdk = "iphoneos",
)

find_xcode_sdk(
    name = "xcode-appletvos",
    sdk = "appletvos",
)

find_xcode_sdk(
    name = "xcode-xros",
    sdk = "xros",
)

# Register the toolchain
toolchain = use_extension("//:extensions.bzl", "toolchain")
use_repo(toolchain, "toolchains")

register_toolchains("@toolchains//...")
